package offer;

import listNodePractice.ListNode;

import java.util.ArrayList;
import java.util.List;

public class Offer06 {


    public int[] reversePrint(ListNode head) {
        ArrayList<Integer> list = new ArrayList<>();
        traverse(head,list);
    int[]  resut=new int[list.size()];
        for (int i = 0; i < list.size(); i++) {
            resut[i]=list.get(i);
        }
return   resut;


    }

    public void traverse(ListNode head, List list) {
        if (head == null) {
            return;
        }
        traverse(head.next, list);
        list.add(head.val);
    }




    public static void main(String[] args) {


    }


}
